package com.atguigu.gmall.realtime.util;

/**
 * @author ming
 * @date 2022/11/22
 * 操作MySQL的工具类
 */
public class MySqlUtil {
    //获取读取字典表数据的建表语句
    public static String getBaseDicLookUpDDL() {
        return "CREATE TABLE base_dic (\n" +
                "  dic_code string,\n" +
                "  dic_name string,\n" +
                "  PRIMARY KEY (dic_code) NOT ENFORCED\n" +
                ") " + mysqlLookUpTableDDL("base_dic");
    }

    //获取JDBC连接器连接属性
    public static String mysqlLookUpTableDDL(String tableName) {
        return " WITH (\n" +
                "'connector' = 'jdbc',\n" +
                "   'url' = 'jdbc:mysql://hadoop102:3306/gmall0620',\n" +
                "   'driver' = 'com.mysql.cj.jdbc.Driver',\n" +
                "   'username' = 'root',\n" +
                "   'password' = '123456',\n" +
                "   'table-name' = '" + tableName + "',\n" +
                "   'lookup.cache.max-rows' = '500',\n" +
                "   'lookup.cache.ttl' = '1 hour'\n" +
                ")";
    }

}
